<template>
	<view class="">
		<view class="bj">
			<view class="heardbox">
				<view class="my">
					我的金币
				</view>
				<view class="gz" @click="rule">
					金币规则
				</view>
			</view>
			<view class="jbzs">
				{{glod}}<text>枚</text>
			</view>
		</view>
		<view class="hr"></view>
		<view class="btnbox">
			<u-tabs :list="tblist" bar-width="110" font-size="26" bg-color="#ffffff" active-color="#FF9933"
				:is-scroll="false" :current="current" @change="change"></u-tabs>
			<view class="listbox" v-for="(item,index) in list" :key="index">
				<view class="leftbox">
					<view class="title">
						{{item.explain}}
					</view>
					<view class="time">
						{{item.create_time}}
					</view>
				</view>
				<view class="rightbox">
					+{{item.money}}
				</view>
			</view>
			
			<u-empty text="暂无记录" mode="list" v-if="list.length==0"></u-empty>
		</view>
	</view>
</template>

<script>
	import {getgoldlist,getuserinfo} from "../../api/api/index.js"
	export default {
		data() {
			return {
				tblist: [{
					name: "收入明细"
				}, {
					name: "支出明细"
				}],
				current: 0,
				page:0,
				limit:20,
				flag:false,
				list:[],
				type:1,
				glod:0
			}
		},
		methods: {
			change(index) {
				this.current = index;
				this.type=index+1
			},
			// 公共接口
			public(){
				if(this.flag){
					this.page=0
					this.list=[]
					this.flag=false
				}
				this.page++
				let data={
					page:this.page,
					limit:this.limit,
					type:this.type
				}
				getgoldlist(data).then(res=>{
					console.log(res.data)
					this.list=res.data
				})
			},
			// 金币规则
			rule(){
				this.jumpLink({link:"/pagesB/gold_rule/index"})
			}
		},
		onShow() {
			this.public()
			getuserinfo().then(res=>{
				this.glod=res.data.gold_coins
			})
		},
		onReachBottom(){
			this.public()
		}
	}
</script>

<style scoped lang="scss">
	.bj {
		width: 100%;
		height: 232rpx;
		background-image: url("http://youjialibo.wm76.mtnet.ren//upload/20210914/c05dea2f42d3195e7fe47edc38d96dcd.png");
		background-size: 750rpx 232rpx;
		padding: 32rpx 21rpx 0 59rpx;
		box-sizing: border-box;

		.heardbox {
			display: flex;
			align-items: center;
			justify-content: space-between;

			.my {
				font-size: 24rpx;
				font-family: PingFang SC;
				font-weight: 500;
				color: #000000;
			}

			.gz {
				background-color: #604A07;
				width: 160rpx;
				height: 55rpx;
				line-height: 55rpx;
				border-radius: 55rpx;
				text-align: center;
				font-size: 24rpx;
				font-family: Microsoft YaHei;
				font-weight: 400;
				color: #FFFFFF;

			}
		}

		.jbzs {
			font-size: 60rpx;
			font-family: PingFang SC;
			font-weight: 800;
			color: #000000;
			margin-top: 32rpx;

			text {
				font-size: 24rpx;
				font-family: PingFang SC;
				font-weight: 500;
				color: #000000;
				margin-left: 20rpx;
			}
		}
	}

	.hr {
		height: 15rpx;
		background: #EDEDED;
		width: 100%;
	}
	.btnbox{
		// background-color: #FFFFFF;
		position: fixed;
		top: 243rpx;
		right: 0;
		left: 0;
		bottom: 0;
		background-color: #FFFFFF;
		overflow: scroll;
		.listbox{
			margin-top: 61rpx;
			display: flex;
			align-items: center;
			justify-content: space-between;
			padding: 20rpx;
			box-sizing: border-box;
			.title{
				font-size: 26rpx;
				font-family: Microsoft YaHei;
				font-weight: 400;
				color: #000000;
			}
			.time{
				font-size: 22rpx;
				font-family: Microsoft YaHei;
				font-weight: 400;
				color: #999999;
				margin-top: 25rpx;
			}
			.rightbox{
				font-size: 30rpx;
				font-family: PingFang SC;
				font-weight: 800;
				color: #FF6600;
				margin-right: 40rpx;
			}
		}
	}
</style>
